﻿using System.Collections.Generic;
using UnityEngine;

namespace MT_ToolKit
{
    public class TimerManager:MonoSingleton<TimerManager>
    {
        private static Dictionary<int, TimerItem> Timer_Dict = new Dictionary<int, TimerItem>();

        public TimerItem CreateTimeItem(int id, int timer = 0)
        {
            if(Timer_Dict.ContainsKey(id))
            {
                Debug.LogError("当前已创建此ID计时器 = " + id);
                return Timer_Dict[id];
            }
            else
            {
                TimerItem item = new TimerItem(id, timer);
                Timer_Dict.Add(id, item);
                return item;
            }
        }

        void Update()
        {
            foreach (var item in Timer_Dict.Values)
            {
                item.SetUpdate(Time.deltaTime);
            }
        }
    }
}